//引入 request 文件
import request from '@/util/request.js'

//发布编辑的文章
export const saveArticle = (articleSaveParam) => {
	return request({
	        url: '/article/save',
	        method: 'post',
	        data: articleSaveParam
	})
}

//通过文章id加载文章详情
export const selectArticleById = (articleId,userId) => {
	return request({
	        url: '/article/select/' + articleId + '/' + userId,
	        method: 'get',
	})
}

//加载所有分类
export const selectArticleCategory = (articleCategoryQueryParam) => {
	return request({
	        url: '/article/list/category',
	        method: 'post',
			data: articleCategoryQueryParam
	})
}

//加载所有标签
export const selectArticleTag = (articleTagQueryParam) => {
	return request({
	        url: '/article/list/tags',
	        method: 'post',
			data: articleTagQueryParam
	})
}

//点赞
export const articleOnLike = (articleId,userId) => {
	return request({
	        url: '/article/onlike/' + articleId + '/' + userId, 
	        method: 'post'
	})
}

//取消点赞
export const articleCancelLike = (articleId,userId) => {
	return request({
	        url: '/article/cancelLike/' + articleId + '/' + userId, 
	        method: 'post'
	})
}

//收藏
export const articleOnFavorite = (articleId,userId) => {
	return request({
	        url: '/article/onfavorite/' + articleId + '/' + userId, 
	        method: 'post'
	})
}

//取消收藏
export const articleCancelFavorite = (articleId,userId) => {
	return request({
	        url: '/article/cancelFavorite/' + articleId + '/' + userId, 
	        method: 'post'
	})
}

//文章浏览记录--增加浏览量
export const articleVisit = (articleId) => {
	return request({
	        url: '/article/visit/' + articleId,
	        method: 'post'
	})
}

//文章保存时同时存入es
export const articleAddToES = (articleId) => {
	return request({
	        url: '/home/es?id='+articleId,
	        method: 'get',
	})
}

//验证是否购买付费
export const doPayConfirm = (articlePayRecordParam) => {
	return request({
	        url: '/wallet/record/select/confirm',
	        method: 'get',
			data: articlePayRecordParam
	})
}

//购买前的准备
export const recordPrepare = (recordParam) => {
	return request({
		    url: '/wallet/record/prepare',
		    method: 'post',
			data: recordParam
	})
}

//确认购买
export const recordAdd = (recordParam) => {
	return request({
		    url: '/wallet/record/add',
		    method: 'post',
			data: recordParam
	})
}

//上传文章封面
// export const uploadArticlePhoto = (articleSaveParam) => {
// 	return request({
// 	        url: '/file/upload',
// 	        method: 'post',
// 	        data: articleSaveParam
// 	})
// }


